package mobi.greenplate.theweb.converter;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import mobi.greenplate.theweb.domain.Address;


@XmlRootElement(name="address-list")
public class AddressListConverter {

    private final List<Address> entities;

    public AddressListConverter() {
        this.entities=new ArrayList<Address>();
    }
    
    public AddressListConverter(List<Address> entities) {
        this.entities = entities;
    }

    @XmlElement
    public List<AddressConverter> getAddress(){
        final List<AddressConverter> list = new ArrayList<AddressConverter>();
        for (Address address : entities) {
            list.add(new AddressConverter(address));
        }
        return list;
    }

    @XmlTransient
    public List<Address> getEntities(){
        return Collections.unmodifiableList(this.entities);
    }

}


